@import "../styles/mixins/index.less";
@import "../styles/themes/index.less";

.@{wux-prefix}-refresher {
    position: absolute;
    top: -60px;
    right: 0;
    left: 0;
    overflow: hidden;
    margin: auto;
    height: 50px;

    &--hidden {
        visibility: hidden;
    }

    &--visible {
        visibility: visible;
    }

    &__content {
        position: absolute;
        bottom: 5px;
        left: 0;
        width: 100%;
        color: @text-color;
        text-align: center;
        font-size: 30px;
    }

    &__content--text {
        bottom: 0;
    }

    &__text-pulling {
        font-size: @font-size-lg;
        line-height: @font-size-lg;
    }

    &__text-refreshing {
        font-size: @font-size-lg;
        line-height: @font-size-lg;
        display: none;
    }

    &__icon-pulling {
        width: 100%;
        backface-visibility: hidden;
        transform-style: preserve-3d;
        padding: 7px 0;
        animation-name: refresh-spin-back;
        animation-duration: .2s;
        animation-timing-function: linear;
        animation-fill-mode: none;
        transform: translateZ(0) rotate(0deg);
    }

    &__icon-refreshing {
        width: 100%;
        backface-visibility: hidden;
        transform-style: preserve-3d;
        padding: 7px 0;
        display: none;
        animation-duration: 1.5s;
    }

    &__icon--arrow-down {
        display: block;
        margin: 0 auto;
        width: 20px;
        height: 20px;
        background-repeat: no-repeat;
        background-position: center center;
        background-size: 20px 20px;
        background-image: url("");
    }

    &__icon--refresher {
        display: block;
        margin: 0 auto;
        width: 20px;
        height: 20px;
        background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg%20viewBox%3D'0%200%20120%20120'%20xmlns%3D'http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg'%20xmlns%3Axlink%3D'http%3A%2F%2Fwww.w3.org%2F1999%2Fxlink'%3E%3Cdefs%3E%3Cline%20id%3D'l'%20x1%3D'60'%20x2%3D'60'%20y1%3D'7'%20y2%3D'27'%20stroke%3D'%236c6c6c'%20stroke-width%3D'11'%20stroke-linecap%3D'round'%2F%3E%3C%2Fdefs%3E%3Cg%3E%3Cuse%20xlink%3Ahref%3D'%23l'%20opacity%3D'.27'%2F%3E%3Cuse%20xlink%3Ahref%3D'%23l'%20opacity%3D'.27'%20transform%3D'rotate(30%2060%2C60)'%2F%3E%3Cuse%20xlink%3Ahref%3D'%23l'%20opacity%3D'.27'%20transform%3D'rotate(60%2060%2C60)'%2F%3E%3Cuse%20xlink%3Ahref%3D'%23l'%20opacity%3D'.27'%20transform%3D'rotate(90%2060%2C60)'%2F%3E%3Cuse%20xlink%3Ahref%3D'%23l'%20opacity%3D'.27'%20transform%3D'rotate(120%2060%2C60)'%2F%3E%3Cuse%20xlink%3Ahref%3D'%23l'%20opacity%3D'.27'%20transform%3D'rotate(150%2060%2C60)'%2F%3E%3Cuse%20xlink%3Ahref%3D'%23l'%20opacity%3D'.37'%20transform%3D'rotate(180%2060%2C60)'%2F%3E%3Cuse%20xlink%3Ahref%3D'%23l'%20opacity%3D'.46'%20transform%3D'rotate(210%2060%2C60)'%2F%3E%3Cuse%20xlink%3Ahref%3D'%23l'%20opacity%3D'.56'%20transform%3D'rotate(240%2060%2C60)'%2F%3E%3Cuse%20xlink%3Ahref%3D'%23l'%20opacity%3D'.66'%20transform%3D'rotate(270%2060%2C60)'%2F%3E%3Cuse%20xlink%3Ahref%3D'%23l'%20opacity%3D'.75'%20transform%3D'rotate(300%2060%2C60)'%2F%3E%3Cuse%20xlink%3Ahref%3D'%23l'%20opacity%3D'.85'%20transform%3D'rotate(330%2060%2C60)'%2F%3E%3C%2Fg%3E%3C%2Fsvg%3E");
        background-repeat: no-repeat;
        background-position: 50%;
        background-size: 100%;
        transform-origin: 50%;
        animation: refresh-spin-rotate 1s steps(12, end) infinite;
    }

    &--active {
        &.@{wux-prefix}-refresher--refreshing {
            transition: transform .2s;
            transform: scale(1);

            .@{wux-prefix}-refresher__icon-pulling,
            .@{wux-prefix}-refresher__text-pulling {
                display: none;
            }

            .@{wux-prefix}-refresher__icon-refreshing,
            .@{wux-prefix}-refresher__text-refreshing {
                display: block;
            }

            .@{wux-prefix}-refresher--refreshing-tail {
                transform: scale(0);
            }
        }

        .@{wux-prefix}-refresher__icon-pulling:not(.@{wux-prefix}-refresher__icon-pulling--disabled) {
            animation-name: refresh-spin;
            transform: translateZ(0) rotate(-180deg);
        }
    }
}

.@{wux-prefix}-loader {
    overflow: hidden;
    margin: auto;
    height: 50px;
    font-size: 15px;
    position: relative;
    text-align: center;
    display: none;

    .@{wux-prefix}-refresher__icon--refresher {
        display: inline-block;
        margin: 0;
    }

    &__text-loading {
        margin-left: @margin-component-base;
    }

    &--hidden {
        visibility: hidden;
        display: none;
    }

    &--visible {
        visibility: visible;
        display: block;
    }

    &--end {
        visibility: visible;
        display: block;
    }

    &__content {
        position: absolute;
        width: 100%;
        top: 50%;
        transform: translateY(-50%);
        color: @text-color;
        display: flex;
        align-items: center;
        justify-content: center;
    }
}

@keyframes refresh-spin {
    0% {
        transform: translateZ(0) rotate(0);
    }

    to {
        transform: translateZ(0) rotate(180deg);
    }
}

@keyframes refresh-spin-back {
    0% {
        transform: translateZ(0) rotate(180deg);
    }

    to {
        transform: translateZ(0) rotate(0);
    }
}

@keyframes refresh-spin-rotate {
    100% {
        transform: rotate(360deg);
    }
}
